package cn.itcast.mybatis.dao;

import cn.itcast.mybatis.pojo.User;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Before;
import org.junit.Test;

import java.io.InputStream;
import java.util.Date;
import java.util.List;

/**
 * Created by Administrator on 2017/9/3.
 */
public class OrderMapperTest {
    public OrderMapper orderMapper;

    @Before
    public void setUp() throws Exception {
        // 读取mybatis的全局配置文件
        InputStream inputStream = Resources.getResourceAsStream("mybatis-config.xml");
        // 构建sqlSessionFactory
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
        // 获取sqlSession会话
        SqlSession sqlSession = sqlSessionFactory.openSession();

        // 初始化userDao
        this.orderMapper = sqlSession.getMapper(OrderMapper.class);
    }

        @Test
    public void testQueryOrderWithUser(){
            System.out.println(this.orderMapper.queryOrderWithUser("20140921001"));
        }

        @Test
    public void testQueryOrderWithUserDetail(){
            System.out.println(this.orderMapper.queryOrderWithUserDetail("20140921001"));
        }

        @Test
    public  void testQueryOrderWithUserDetailItem(){
            System.out.println(this.orderMapper.queryOrderWithUserDetailItem("20140921001"));
        }
}
